import { createSlice, PayloadAction } from '@reduxjs/toolkit'
// 为 slice state 定义一个类型
interface CounterState {
  isShow: boolean,
  token:string,
}

// 使用该类型定义初始 state
const initialState: CounterState = {
  isShow: false,
  token:"",
}

export const showSlice = createSlice({
  name: 'counter',
  // `createSlice` 将从 `initialState` 参数推断 state 类型
  initialState,
  reducers: {
    // 使用 PayloadAction 类型声明 `action.payload` 的内容
    showAmount: (state, action: PayloadAction<boolean>) => {
      state.isShow = action.payload
    },
    //存入token
    settoken: (state, action: PayloadAction<string>) => {
      state.token=action.payload
    }
  }
})

export const { showAmount,settoken } = showSlice.actions
// 选择器等其他代码可以使用导入的 `RootState` 类型


export default showSlice.reducer